<div id="sidebar">
    <?php get_search_form(); ?>
    <div class="box">
        <h2>Categories</h2>
        <ul id="categories">
            <?php wp_list_categories('title_li='); ?>
        </ul>
        <div class="clear"></div>
    </div>                    
    <?php if(!function_exists('dynamic_sidebar') || !dynamic_sidebar('Ads Sidebar')) : ?>
    <?php endif; ?>
    
    <div class="box border-top">
        <h2>Popular Posts</h2>
        <span>Read our best posts >></span>
        <ul>
            <?php echo popularPosts(10); ?>
        </ul>
    </div><!--end .box-->
    <?php if(!function_exists('dynamic_sidebar') || !dynamic_sidebar('Main Sidebar')) : ?>
    <?php endif; ?>

</div><!--end #sidebar-->